﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using ARR.Entities.Gateways;

namespace ARR.Entities
{
    public partial class ArticleSale
    {
        [DataMember]
        public string Category
        {
            get { return row.Category; }
            set { row.Category = value; }
        }

        [DataMember]
        public string Subcategory
        {
            get { return row.Subcategory; }
            set { row.Subcategory = value; }
        }

        [DataMember]
        public string ArticleName
        {
            get { return row.ArticleName; }
            set { row.ArticleName = value; }
        }

        [DataMember]
        public string ArticleCode
        {
            get { return row.ArticleCode; }
            set { row.ArticleCode = value; }
        }

        [DataMember]
        public string UOM
        {
            get { return row.UOM; }
            set { row.UOM = value; }
        }

        [DataMember]
        public string StoreName
        {
            get { return row.StoreName; }
            set { row.StoreName = value; }
        }

        [DataMember]
        public decimal NetMarginCalc
        {
            get 
            {
                if (row.NetMargin.HasValue && row.NetMargin.Value > 0)
                    return row.NetMargin.Value;
                else
                {
                    decimal res = GM;
                    res += PIDiff.HasValue ? PIDiff.Value : 0;
                    res += ChargeOffs.HasValue ? PIDiff.Value : 0;
                    res += Rebates.HasValue ? PIDiff.Value : 0;

                    return res;
                }
            }
            set { row.NetMargin = value; }
        }
    }
}
